package com.example.hello;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.ArrayList;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class RateAdapter extends ArrayAdapter {


    public RateAdapter(@NonNull Context context, int resource, ArrayList<Rate> item) {
        super(context, resource, item);
    }

    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        View itemView=convertView;
        if(itemView==null){
            itemView= LayoutInflater.from(getContext()).inflate(R.layout.list_item,parent,
                    false);
        }
        Rate item=(Rate)getItem(position);
        TextView country=(TextView)itemView.findViewById(R.id.item_title);
        TextView rate=(TextView)itemView.findViewById(R.id.item_detail);
        country.setText("RateAdapter:Country-"+item.getCountry());
        rate.setText("RateAdapter:Rate-"+item.getRate());
        return itemView;
    }
}
